package com.autonavi.collapse.concurrent;

import java.util.concurrent.*;

public class AsyncThreadPool extends ThreadPoolExecutor {

    public AsyncThreadPool(int poolSize){
        super(poolSize, poolSize, 0, TimeUnit.MILLISECONDS, new LinkedBlockingDeque<>(poolSize),
                (r, executor)->{
                    try {
                        executor.getQueue().put(r);
                    }catch (InterruptedException e){

                    }
                });
    }

    public AsyncThreadPool(int poolSize, ThreadFactory factory) {
        super(poolSize, poolSize, 0, TimeUnit.MILLISECONDS, new LinkedBlockingDeque<>(poolSize), factory,
                (r, executor)->{
                    try {
                        executor.getQueue().put(r);
                    }catch (InterruptedException e){

                    }
                });
    }
}
